from rest_framework import serializers
from goods.models import SPUSpecification


# 1.spec序列化器
class SpecViewSetSerializer(serializers.ModelSerializer):
    # 1.spu重写
    spu = serializers.StringRelatedField(read_only=True)  # StringRelatedField此字段将被序列化为关联对象的字符串表示方式（即__str__方法的返回值）
    spu_id = serializers.IntegerField()

    class Meta:
        model = SPUSpecification
        fields = '__all__'
